package com.yiren.backstage.judge.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Time:2021/11/10 11:03
 * Author:xiaozan
 * Description:可缓存线程池 管理类
 */
public class CachedThreadPoolManage  {

    private ExecutorService executorService;

    public CachedThreadPoolManage(){
        executorService = Executors.newCachedThreadPool();
    }

    private static final CachedThreadPoolManage single = new CachedThreadPoolManage();

    public static CachedThreadPoolManage getInstance() {
        return single;
    }

    public  void startThread(Runnable runnable){
        executorService.execute(runnable);
    }

    public void closeAllThread(){
        executorService.shutdownNow();
    }
}
